#!/usr/bin/env node
const http=require('http'),
      log=console.log;
http.createServer((res,req)=>{
  log(`${req.method} ${req.url} HTTP/${req.httpVersion}`);
  log(req.headers);
  log('');
  log('Host:',req.header.host);
  log('User-Agent:',req.header['user-agent']);
  log('Content-Type:',req.headers['content-type']);
  log('');
  log('authorization:'req.header.authorization);
  let auth=req.header.authorization;
  if(typeof auth !=='undefined'){
    auth=auth.split('');
    if(auth[0]==='Basic'){
      let buf=new Buffer(auth[1].'base64');
      log('username & password:',nuf.toString('utf8'));
    }

  }
res.end('ok!')
}),listen(8080);
     
console.log('hello world');
